﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WinShare
{
    public partial class aboutConfig : Form
    {
        public aboutConfig()
        {
            InitializeComponent();
        }

        private void aboutConfig_Load(object sender, EventArgs e)
        {
            propertyGrid1.SelectedObject = WinShare.Properties.Settings.Default;
            System.Configuration.UserScopedSettingAttribute userAttr = new System.Configuration.UserScopedSettingAttribute();
            System.ComponentModel.AttributeCollection attrs = new AttributeCollection(userAttr);
            propertyGrid1.BrowsableAttributes = attrs;
            propertyGrid2.SelectedObject = WinShare.Properties.Settings.Default;
            System.Configuration.ApplicationScopedSettingAttribute appAttr = new System.Configuration.ApplicationScopedSettingAttribute();
            System.ComponentModel.AttributeCollection appAttrs = new AttributeCollection(appAttr);
            propertyGrid2.BrowsableAttributes = appAttrs;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to reset all settings?" + Environment.NewLine +
                "(The current settings will be lost forever beneath the streets of Boston)", "Reset Settings", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
            {
                WinShare.Properties.Settings.Default.Reset();
                WinShare.Properties.Settings.Default.Save();
                if(MessageBox.Show("Would you like to resart WinShare now? (Recommended)", "Application Restart", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes){
                    Application.Restart();
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            WinShare.Properties.Settings.Default.Save();
            this.Close();
        }
    }
}
